/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @Title: PlfUserInfoForm
 * @Package com.rx.com.rx.stock.vo
 * @Description: 用户信息表单
 * @author: 陈锦韬
 * @date: 2020\9\8 0008
 * @version V1.0
 * @Copyright: 2020 陈锦韬  All rights reserved.
 */
package com.rx.school.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.rx.core.data.RxData;
import com.rx.core.dbase.RxMarkDbMust;
import com.rx.core.util.RxUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

/**
 * @author: Administrator
 * @Description: 考试管理
 * @date: 2020\9\8 0008
 */
@RxData
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SchExamInfo extends RxMarkDbMust  {
    private static final long serialVersionUID = 1L;
    @TableField("STATUS")
    private String status;
    @TableField("PARENT_BID")
    private String parentBid;
    @TableField("ORG_BID")
    private String orgBid;
    @TableField("BATCH")
    private String batch;
    @TableField("NAME")
    private String name;
    @TableField("YEAR")
    private String year;
    @TableField("COUNT")
    private Integer count;
    // 语文
    @TableField("CHINESE_PASS_COUNT")
    private Integer chinesePassCount;
    @TableField("CHINESE_PASS_RATE")
    private BigDecimal chinesePassRate;
    @TableField("CHINESE_AVG")
    private BigDecimal chineseAvg;
    // 数学
    @TableField("MATH_PASS_COUNT")
    private Integer mathPassCount;
    @TableField("MATH_PASS_RATE")
    private BigDecimal mathPassRate;
    @TableField("MATH_AVG")
    private BigDecimal mathAvg;
    // 英语
    @TableField("ENGLISH_PASS_COUNT")
    private Integer englishPassCount;
    @TableField("ENGLISH_PASS_RATE")
    private BigDecimal englishPassRate;
    @TableField("ENGLISH_AVG")
    private BigDecimal englishAvg;
    // 物理
    @TableField("PHYSICAL_PASS_COUNT")
    private Integer physicalPassCount;
    @TableField("PHYSICAL_PASS_RATE")
    private BigDecimal physicalPassRate;
    @TableField("PHYSICAL_AVG")
    private BigDecimal physicalAvg;
    // 化学
    @TableField("CHEMICAL_PASS_COUNT")
    private Integer chemicalPassCount;
    @TableField("CHEMICAL_PASS_RATE")
    private BigDecimal chemicalPassRate;
    @TableField("CHEMICAL_AVG")
    private BigDecimal chemicalAvg;
    // 生物
    @TableField("BIOLOGICAL_PASS_COUNT")
    private Integer biologicalPassCount;
    @TableField("BIOLOGICAL_PASS_RATE")
    private BigDecimal biologicalPassRate;
    @TableField("BIOLOGICAL_AVG")
    private BigDecimal biologicalAvg;
    // 政治
    @TableField("POLITICAL_PASS_COUNT")
    private Integer politicalPassCount;
    @TableField("POLITICAL_PASS_RATE")
    private BigDecimal politicalPassRate;
    @TableField("POLITICAL_AVG")
    private BigDecimal politicalAvg;
    // 历史
    @TableField("HISTORY_PASS_COUNT")
    private Integer historyPassCount;
    @TableField("HISTORY_PASS_RATE")
    private BigDecimal historyPassRate;
    @TableField("HISTORY_AVG")
    private BigDecimal historyAvg;
    // 地理
    @TableField("GEOGRAPHIC_PASS_COUNT")
    private Integer geographicPassCount;
    @TableField("GEOGRAPHIC_PASS_RATE")
    private BigDecimal geographicPassRate;
    @TableField("GEOGRAPHIC_AVG")
    private BigDecimal geographicAvg;
    // 其他
    @TableField("OTHER_PASS_COUNT")
    private Integer otherPassCount;
    @TableField("OTHER_PASS_RATE")
    private BigDecimal otherPassRate;
    @TableField("OTHER_AVG")
    private BigDecimal otherAvg;

    @TableField("STYLE_JSON")
    private String styleJson;
    @TableField("REMARK")
    private String remark;

    public void calcAvg(SchScoresInfo total){
        setChineseAvg(RxUtil.Amount.divideRound(total.getChineseScores(),getCount()));
        setMathAvg(RxUtil.Amount.divideRound(total.getMathScores(),getCount()));
        setEnglishAvg(RxUtil.Amount.divideRound(total.getEnglishScores(),getCount()));
        setPhysicalAvg(RxUtil.Amount.divideRound(total.getPhysicalScores(),getCount()));
        setChemicalAvg(RxUtil.Amount.divideRound(total.getChemicalScores(),getCount()));
        setBiologicalAvg(RxUtil.Amount.divideRound(total.getBiologicalScores(),getCount()));
        setPoliticalAvg(RxUtil.Amount.divideRound(total.getPoliticalScores(),getCount()));
        setHistoryAvg(RxUtil.Amount.divideRound(total.getHistoryScores(),getCount()));
        setGeographicAvg(RxUtil.Amount.divideRound(total.getGeographicScores(),getCount()));
    }

    public void calcPassRate(){
        setChinesePassRate(   RxUtil.Amount.divideRound(BigDecimal.valueOf(getChinesePassCount()),getCount()));
        setMathPassRate(      RxUtil.Amount.divideRound(BigDecimal.valueOf(getMathPassCount()),getCount()));
        setEnglishPassRate(   RxUtil.Amount.divideRound(BigDecimal.valueOf(getEnglishPassCount()),getCount()));
        setPhysicalPassRate(  RxUtil.Amount.divideRound(BigDecimal.valueOf(getPhysicalPassCount()),getCount()));
        setChemicalPassRate(  RxUtil.Amount.divideRound(BigDecimal.valueOf(getChemicalPassCount()),getCount()));
        setBiologicalPassRate(RxUtil.Amount.divideRound(BigDecimal.valueOf(getBiologicalPassCount()),getCount()));
        setPoliticalPassRate( RxUtil.Amount.divideRound(BigDecimal.valueOf(getPoliticalPassCount()),getCount()));
        setHistoryPassRate(   RxUtil.Amount.divideRound(BigDecimal.valueOf(getHistoryPassCount()),getCount()));
        setGeographicPassRate(RxUtil.Amount.divideRound(BigDecimal.valueOf(getGeographicPassCount()),getCount()));
    }

    private boolean pass(BigDecimal scores,BigDecimal fullScores){
        BigDecimal passScores = RxUtil.Amount.multiply(fullScores,BigDecimal.valueOf(0.6));

        return RxUtil.Amount.biggerOr(scores,passScores);
    }
    private Integer increasePassCount(Integer integer){
        if(integer == null){
            return Integer.valueOf(1);
        }
        return integer + 1;
    }
    public void zeroPassCount(){
        chinesePassCount = 0;
        mathPassCount = 0;
        englishPassCount = 0;
        physicalPassCount = 0;
        chemicalPassCount = 0;
        biologicalPassCount = 0;
        politicalPassCount = 0;
        historyPassCount = 0;
        geographicPassCount = 0;

    }
    public void calcPassCount(SchScoresInfo total,SchFullScores fullScores){
        if(pass(total.getChineseScores(),fullScores.getChineseScores())){
            chinesePassCount = increasePassCount(getChinesePassCount());
        }
        if(pass(total.getMathScores(),fullScores.getMathScores())){
            mathPassCount = increasePassCount(getMathPassCount());
        }
        if(pass(total.getEnglishScores(),fullScores.getEnglishScores())){
            englishPassCount = increasePassCount(englishPassCount);
        }
        if(pass(total.getPhysicalScores(),fullScores.getPhysicalScores())){
            physicalPassCount = increasePassCount(physicalPassCount);
        }
        if(pass(total.getChemicalScores(),fullScores.getChemicalScores())){
            chemicalPassCount = increasePassCount(chemicalPassCount);
        }
        if(pass(total.getBiologicalScores(),fullScores.getBiologicalScores())){
            biologicalPassCount = increasePassCount(biologicalPassCount);
        }
        if(pass(total.getPoliticalScores(),fullScores.getPoliticalScores())){
            politicalPassCount = increasePassCount(getPoliticalPassCount());
        }
        if(pass(total.getHistoryScores(),fullScores.getHistoryScores())){
            historyPassCount = increasePassCount(getHistoryPassCount());
        }
        if(pass(total.getGeographicScores(),fullScores.getGeographicScores())){
            geographicPassCount = increasePassCount(getGeographicPassCount());
        }

    }

}
